package org.fanximall.erp.system.infrastructure.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.fanximall.erp.system.domain.aggregate.UserAggregate;
import org.fanximall.erp.system.domain.repository.UserRepository;
import org.fanximall.erp.system.infrastructure.convert.UserConverter;
import org.fanximall.erp.system.infrastructure.dao.entity.SysUserDO;
import org.fanximall.erp.system.infrastructure.dao.mapper.SysUserMapper;

import javax.annotation.Resource;

/**
 * @author :  william
 * @version :  V1.0  created in 2024/4/22
 */
public class UserRepositoryImpl implements UserRepository {

    @Resource
    private SysUserMapper userMapper;

    @Resource
    private UserConverter userConverter;

    @Override
    public UserAggregate findByUserName(String userName) {
        SysUserDO sysUserDO = userMapper.selectOne(new LambdaQueryWrapper<SysUserDO>().eq(SysUserDO::getUserName, userName));
        return userConverter.toUserAggregate(sysUserDO);
    }
}
